package com.zhanghe.study.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 文件上传测试
 * @author zh
 * @date 2021/1/9 16:35
 */
@Controller
@RequestMapping("fileUpload")
public class FileUploadController {

    @ResponseBody
    @RequestMapping(value = "testUpload",method = RequestMethod.POST)
    public String testUpload(@RequestPart("file")MultipartFile file) throws IOException {
        System.out.println(file.getName());
        System.out.println(file.getBytes());
        return "success";
    }

}
